﻿package mortal.game.view.achievement.panel
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.achievement.item.*;
    import mortal.game.view.common.*;

    public class AchievementCurTotalPanel extends GSprite
    {
        private var _rightBg:GImageBitmap;
        private var _rightBottomBg:ScaleBitmap;
        private var _totalCellArr:Array;
        private var _preFinishLabel:GBitmap;
        private var _preFinishCell:Array;

        public function AchievementCurTotalPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._rightBg = UIFactory.gImageBitmap(ImagesConst.AchievementCurTotalRightBg, 0, 0, this);
            this._rightBottomBg = UIFactory.bg(0, 378, 640, 129, this);
            this._preFinishLabel = UIFactory.bitmap(ImagesConst.AchievemenUpcomingTitle, 18, 390, this);
            this.genCells(null);
            return;
        }// end function

        private function genCells(param1:Array) : void
        {
            var _loc_5:int = 0;
            var _loc_7:int = 0;
            var _loc_9:AchievementTotalCell = null;
            var _loc_10:AchievementPreFinishCell = null;
            var _loc_2:int = 4;
            var _loc_3:int = 7;
            var _loc_4:int = 20;
            _loc_5 = 5;
            var _loc_6:int = 150;
            _loc_7 = 183;
            this._totalCellArr = [];
            var _loc_8:int = 0;
            _loc_8 = 0;
            while (_loc_8 < _loc_3)
            {
                
                _loc_9 = UICompomentPool.getUICompoment(AchievementTotalCell) as AchievementTotalCell;
                _loc_9.x = _loc_4 + _loc_6 * int(_loc_8 % _loc_2);
                _loc_9.y = _loc_5 + _loc_7 * int(_loc_8 / _loc_2);
                this.addChild(_loc_9);
                this._totalCellArr.push(_loc_9);
                _loc_8++;
            }
            _loc_2 = 5;
            _loc_3 = 5;
            _loc_4 = 82;
            _loc_5 = 390;
            _loc_6 = 110;
            _loc_7 = 183;
            this._preFinishCell = [];
            _loc_8 = 0;
            while (_loc_8 < _loc_3)
            {
                
                _loc_10 = UICompomentPool.getUICompoment(AchievementPreFinishCell) as AchievementPreFinishCell;
                _loc_10.x = _loc_4 + _loc_6 * int(_loc_8 % _loc_2);
                _loc_10.y = _loc_5;
                this.addChild(_loc_10);
                this._preFinishCell.push(_loc_10);
                _loc_8++;
            }
            return;
        }// end function

        public function initCategory(param1:Array) : void
        {
            var _loc_3:SAchievementCategory = null;
            var _loc_4:AchievementTotalCell = null;
            if (param1 == null || param1.length == 0)
            {
                return;
            }
            var _loc_2:int = 0;
            while (_loc_2 < param1.length && _loc_2 < this._totalCellArr.length)
            {
                
                _loc_3 = param1[_loc_2];
                _loc_4 = this._totalCellArr[_loc_2];
                _loc_4.updateCell(_loc_3);
                _loc_2++;
            }
            return;
        }// end function

        public function initUpComing(param1:Array) : void
        {
            var _loc_3:SAchievementType = null;
            var _loc_4:AchievementPreFinishCell = null;
            if (param1 == null || param1.length == 0)
            {
                return;
            }
            var _loc_2:int = 0;
            while (_loc_2 < param1.length && _loc_2 < this._preFinishCell.length)
            {
                
                _loc_3 = param1[_loc_2];
                _loc_4 = this._preFinishCell[_loc_2];
                _loc_4.updateCell(_loc_3);
                _loc_2++;
            }
            return;
        }// end function

        public function updateCategoryByInfo(param1:SAchievementCategory) : void
        {
            var _loc_3:AchievementTotalCell = null;
            var _loc_2:int = 0;
            while (_loc_2 < this._totalCellArr.length)
            {
                
                _loc_3 = this._totalCellArr[_loc_2];
                if (_loc_3.updateByInfo(param1))
                {
                    break;
                }
                _loc_2++;
            }
            return;
        }// end function

        public function flyCatoryIcon() : void
        {
            var _loc_3:AchievementTotalCell = null;
            var _loc_1:* = Cache.instance.achievent.getCatoryType;
            Cache.instance.achievent.getCatoryType = -1;
            if (_loc_1 == -1 || this._totalCellArr == null)
            {
                return;
            }
            var _loc_2:int = 0;
            while (_loc_2 < this._totalCellArr.length)
            {
                
                _loc_3 = this._totalCellArr[_loc_2];
                if (_loc_3.flyIcon(_loc_1))
                {
                    break;
                }
                _loc_2++;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            var _loc_3:AchievementTotalCell = null;
            var _loc_4:AchievementPreFinishCell = null;
            super.disposeImpl(param1);
            this._rightBg.dispose(param1);
            this._rightBg = null;
            this._rightBottomBg.dispose(param1);
            this._rightBottomBg = null;
            this._preFinishLabel.dispose(param1);
            this._preFinishLabel = null;
            var _loc_2:int = 0;
            _loc_2 = 0;
            while (_loc_2 < this._totalCellArr.length)
            {
                
                _loc_3 = this._totalCellArr[_loc_2];
                _loc_3.dispose(param1);
                _loc_2++;
            }
            this._totalCellArr = null;
            _loc_2 = 0;
            while (_loc_2 < this._preFinishCell.length)
            {
                
                _loc_4 = this._preFinishCell[_loc_2];
                _loc_4.dispose(param1);
                _loc_2++;
            }
            this._preFinishCell = null;
            return;
        }// end function

    }
}
